import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;


public class About extends Dialog {

	protected Object result;
	protected Shell shlOm;

	/**
	 * Create the dialog.
	 * @param parent
	 * @param style
	 */
	public About(Shell parent, int style) {
		super(parent, style);
		setText("SWT Dialog");
	}

	/**
	 * Open the dialog.
	 * @return the result
	 */
	public Object open() {
		createContents();
		shlOm.open();
		shlOm.layout();
		Display display = getParent().getDisplay();
		while (!shlOm.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}
	


	/**
	 * Create contents of the dialog.
	 */
	private void createContents() {
		shlOm = new Shell(getParent(), getStyle());
		shlOm.setSize(410, 682);
		shlOm.setText("Om");
		
		Button btnLukk = new Button(shlOm, SWT.NONE);
		btnLukk.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				shlOm.dispose();
			}

			
		});
		btnLukk.setBounds(159, 619, 75, 25);
		btnLukk.setText("Lukk");
		
		CLabel lblNewLabel = new CLabel(shlOm, SWT.NONE);
		lblNewLabel.setBounds(10, 10, 424, 21);
		lblNewLabel.setText("Program for \u00E5 beregne titrering av 50mL 0,1M HCl med 0,1M NaOH.");
		
		Canvas canvas = new Canvas(shlOm, SWT.NONE);
		canvas.setBounds(10, 37, 380, 480);
		
		CLabel lblNewLabel_1 = new CLabel(shlOm, SWT.NONE);
		lblNewLabel_1.setBounds(10, 523, 380, 90);
		lblNewLabel_1.setText("Kjemiprosjekt 2.ing v\u00E5ren 2010.\r\nProgrammet er laget av:\r\nSondre M\u00E6re Overskaug og Magnus Skoms\u00F8y Bae\r\nAlle avvik i tall skyldes datamaskiners grunnleggende problemer \r\nmed flyttallberegninger ved sm\u00E5 tall.");
		
		Label lblVersjon = new Label(shlOm, SWT.NONE);
		lblVersjon.setBounds(325, 629, 69, 15);
		lblVersjon.setText("Versjon 1.0");
		Display display = shlOm.getDisplay();
		Image bilde = new Image(display, "about.jpg");		
		GC gc = null;
		if(bilde != null){
			gc = new GC(bilde);
			canvas.setBackgroundImage(bilde);
		}
		
	}
}
